﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;

namespace Chenxin.Lib.House.DAL
{
    class HouseSendLog
    {
        #region  成员方法
        public static void Add(Chenxin.Lib.House.Entity.HouseSendLog houseSend)
        {
            string strSQL = "insert into House_SendHouseLog(RecordId,HouseId,HouseCode,HouseAddress,OprUserId,OprDepartId,SendUserId,SendUserDepart,SendTarget,SendTargetUrl,SendAjkReturnHouseId,SendAjkReturnCummId) " +
                "values ('" + houseSend.RecordId + "','" + houseSend.HouseId + "','" + houseSend.HouseCode + "','" + houseSend.HouseAddress + "',"+
                " '"+houseSend.OprUserId+"','"+houseSend.OprDepartId+"', '" + houseSend.SendUserId + "','" + houseSend.SendUserDepartId + "','" + houseSend.SendTarget + "','" + houseSend.SendTargetUrl + "','"+houseSend.SendAjkReturnHouseId+"','"+houseSend.SendAjkReturnCummId+"') ";
            Database db = DatabaseFactory.CreateDatabase("Chenxin_House_Search");
            int count = db.ExecuteNonQuery(CommandType.Text, strSQL);

        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from House_SendHouseLog ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase("Chenxin_House_Search");
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }

        /// <summary>
        /// 删除数据列表
        /// </summary>
        public static int Delete(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from House_SendHouseLog ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase("Chenxin_House_Search");
            int count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
            return count;
        }
        #endregion
    }
}
